﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using IBupro.Models.Classes;
using iBuproModel;

namespace IBupro.Models
{
    public class UserModel : CustomModel
    {
        public UserModel(User user)
        {
            this.User = user;
        }

        public UserModel() {}

        public User User { get; set; }
        
        public MultiSelectList MultiSelectListRoles()
        {
            var actualRoles = User.Roles.Select(role => role.Id.ToString()).ToList();

            var roleRepository = repositoryService.RoleRepositoryCreateInstance();

            IEnumerable roles = from r in roleRepository.GetAll().ToList()
                                select new {Id = r.Id, Name = r.Name};

            return new MultiSelectList(roles, "Id", "Name", actualRoles);
        }
        
        public IEnumerable<int> SelectedRoles { get; set; }

    }
}